<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
		<title>南山郦都夜景</title>

		<link href="Build/Cesium/Widgets/widgets.css" rel="stylesheet">
		<link href="css/font-awesome.min.css" rel="stylesheet">
		<link href="css/bootstrap.min.css" rel="stylesheet">
		<link href="css/pretty.css" rel="stylesheet">
		<script src="js/night/jquery.min.js"></script>
		<script src="js/night/bootstrap.min.js"></script>
		<script src="js/night/bootstrap-select.min.js"></script>
		<script src="js/night/config.js"></script>
		<script src="js/night/spectrum.js"></script>
		<script type="text/javascript" src="js/night/require.min.js" data-main="js/main1"></script>
	</head>
	<body>
		<div id="cesiumContainer"></div>
		<!-- <div id="tool-bar" class="param-container tool-bar">
			<label style="color: #FFFFFF" for="circulation">循环旋转</label>
			<input type="checkbox" id="circulation" checked=true>&nbsp&nbsp&nbsp
			<button id="start" class="button black">点选旋转</button>&nbsp&nbsp&nbsp
			<button id="stop" class="button black">停止旋转</button>
		</div> -->
		<script type="text/javascript">
			/*示范代码说明：
			 *选取一个点作为中心点，并以此做旋转
			 *
			 *主要涉及接口：
			 * camera.flyCircle
			 * camera.flyCircleLoop
			 * camera.stopFlyCircle
			 * 示范代码：
			 */
			function onload(Cesium) {
				var viewer = new Cesium.Viewer('cesiumContainer');
				viewer.imageryLayers.addImageryProvider(new Cesium.BingMapsImageryProvider({
					url: 'https://dev.virtualearth.net',
					mapStyle: Cesium.BingMapsStyle.AERIAL,
					key: URL_CONFIG.BING_MAP_KEY
				}));
				var scene = viewer.scene;
				var widget = viewer.cesiumWidget;
				
				try {
					var promise = scene.open('http://localhost:8091/iserver/services/3D-nanshanlidu_new/rest/realspace');
					Cesium.when(promise, function(layer) {
							var style3D = new Cesium.Style3D();
							layer.style3D = style3D;
							style3D.bottomAltitude = 1000;
							//点击旋转
							var camera = scene.camera;
							camera.flyCircleLoop = true; // 相机绕点旋转开启循环模式
							var center = new Cesium.Cartesian3(0, 0, 0);
							var handlerPoint = new Cesium.DrawHandler(viewer, Cesium.DrawMode.Point);
							handlerPoint.drawEvt.addEventListener(
								function(result) {
									center = result.object.position;
									camera.flyCircle(center); // 相机绕中心点旋转
								});
							$('#start').click(function() {
								handlerPoint.activate();
							});
							$('#circulation').on("input propertychange", function() {
								camera.flyCircleLoop = this.checked; // 设置绕点旋转是否循环
							});
							$("#stop").click(function() {
								camera.stopFlyCircle(); // 停止相机绕中心点旋转
							});							
						},
						function(e) {
							if (widget._showRenderLoopErrors) {
								var title = '加载SCP失败，请检查网络连接状态或者url地址是否正确？';
								widget.showErrorPanel(title, undefined, e);
							}
						});
				} catch (e) {
					if (widget._showRenderLoopErrors) {
						var title = '渲染时发生错误，已停止渲染。';
						widget.showErrorPanel(title, undefined, e);
					}
				}

			}
		</script>
	</body>
</html>
